package com.liuzh.deviceinfo.tab.screen;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.FontMetrics;
import android.graphics.Point;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import c.h.a.m0.h;
import com.liuzh.deviceinfo.DeviceInfoApp;
import java.util.Locale;

public class ScreenSizeView extends View {
    public Paint a;
    public int b;
    public int c;
    public float d;
    public float e;
    public int f;
    public String g;
    public String h;
    public String i;
    public String j;
    public String k;

    public ScreenSizeView(Context context) {
        float f;
        super(context);
        Paint paint = new Paint(1);
        this.a = paint;
        paint.setColor(-1);
        this.a.setStrokeWidth((float) h.t(2.0f, getResources().getDisplayMetrics()));
        this.a.setTextSize((float) h.u(13.0f, getResources().getDisplayMetrics()));
        this.a.setFakeBoldText(true);
        setBackgroundColor(-16777216);
        Point k = h.k();
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(k.x);
        stringBuilder.append(getResources().getString(2131690212));
        this.g = stringBuilder.toString();
        stringBuilder = new StringBuilder();
        stringBuilder.append(k.y);
        stringBuilder.append(getResources().getString(2131690212));
        this.h = stringBuilder.toString();
        StringBuilder stringBuilder2 = new StringBuilder();
        Locale locale = Locale.US;
        Object[] objArr = new Object[1];
        Point point = new Point();
        String str = "window";
        WindowManager windowManager = (WindowManager) DeviceInfoApp.c.getSystemService(str);
        float f2 = 0.0f;
        if (windowManager != null) {
            Display defaultDisplay = windowManager.getDefaultDisplay();
            defaultDisplay.getRealSize(point);
            DisplayMetrics displayMetrics = new DisplayMetrics();
            defaultDisplay.getRealMetrics(displayMetrics);
            f = ((float) point.x) / displayMetrics.xdpi;
        } else {
            f = 0.0f;
        }
        objArr[0] = Float.valueOf(f);
        String str2 = "%.1f";
        stringBuilder2.append(String.format(locale, str2, objArr));
        stringBuilder2.append(getResources().getString(2131690005));
        this.i = stringBuilder2.toString();
        stringBuilder2 = new StringBuilder();
        objArr = new Object[1];
        Point point2 = new Point();
        WindowManager windowManager2 = (WindowManager) DeviceInfoApp.c.getSystemService(str);
        if (windowManager2 != null) {
            Display defaultDisplay2 = windowManager2.getDefaultDisplay();
            defaultDisplay2.getRealSize(point2);
            DisplayMetrics displayMetrics2 = new DisplayMetrics();
            defaultDisplay2.getRealMetrics(displayMetrics2);
            f2 = ((float) point2.y) / displayMetrics2.ydpi;
        }
        objArr[0] = Float.valueOf(f2);
        stringBuilder2.append(String.format(locale, str2, objArr));
        stringBuilder2.append(getResources().getString(2131690005));
        this.j = stringBuilder2.toString();
        stringBuilder2 = new StringBuilder();
        stringBuilder2.append(String.format(locale, str2, new Object[]{Float.valueOf(h.l())}));
        stringBuilder2.append(getResources().getString(2131690005));
        this.k = stringBuilder2.toString();
    }

    public void onDraw(Canvas canvas) {
        this.a.setColor(-1);
        canvas.drawLine((float) getWidth(), 0.0f, 0.0f, (float) getHeight(), this.a);
        canvas.drawText(this.k, (float) ((int) (((double) this.b) * 1.525d)), (float) ((int) (((float) this.c) * 0.525f)), this.a);
        this.a.setColor(-16711936);
        int i = this.b;
        canvas.drawLine((float) i, 0.0f, (float) i, (float) getHeight(), this.a);
        canvas.drawText(this.h, (float) (this.b + 14), (float) this.f, this.a);
        canvas.drawText(this.j, (float) (this.b + 14), ((float) this.f) + this.e, this.a);
        this.a.setColor(-65536);
        canvas.drawLine(0.0f, (float) this.c, (float) getWidth(), (float) this.c, this.a);
        canvas.drawText(this.g, this.d, ((float) (this.c + 4)) + this.e, this.a);
        canvas.drawText(this.i, this.d, (this.e * 2.0f) + ((float) (this.c + 4)), this.a);
    }

    public void onSizeChanged(int i, int i2, int i3, int i4) {
        super.onSizeChanged(i, i2, i3, i4);
        i /= 2;
        this.b = i;
        i2 /= 2;
        this.c = i2;
        this.d = (float) (((double) i) * 1.4d);
        this.f = (int) (((double) i2) * 1.5d);
        FontMetrics fontMetrics = this.a.getFontMetrics();
        this.e = fontMetrics.bottom - fontMetrics.top;
    }
}
